//
//  LJFFuYongTableViewCell.m
//  GiftThat
//
//  Created by 刘景峰 on 16/1/16.
//  Copyright © 2016年 ChuXiang. All rights reserved.
//

#import "LJFFuYongTableViewCell.h"
#define Labwidth [UIScreen mainScreen].bounds.size.width
@interface LJFFuYongTableViewCell ()
@property (nonatomic,assign) NSInteger number;
@property (nonatomic,strong)   UIImageView *underImage;

@end


@implementation LJFFuYongTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self GetData];
       
        
    }
    return self;
}
-(void)GetData{
    self.imageViews = [[UIImageView alloc] init];
    self.imageViews.userInteractionEnabled = YES;
    [self addSubview:self.imageViews];
    self.underImage = [[UIImageView alloc]init];
    self.underImage.image = [UIImage imageNamed:@"under"];
    [self addSubview:self.underImage];
    
    self.label = [[UILabel alloc] init];
    self.label.textColor = [UIColor whiteColor];
    self.label.font = [UIFont systemFontOfSize:15];
    self.label.numberOfLines = 0;
    
    [self addSubview:self.label];
    
    
    
    
    
    
    
}

-(void)setSelectionCellModel:(SFSelectionCellModel *)SelectionCellModel{
    if (_SelectionCellModel != SelectionCellModel) {
        _SelectionCellModel = SelectionCellModel;
        
    }
    
    
    [self.imageViews sd_setImageWithURL:[NSURL URLWithString:self.SelectionCellModel.cover_image_url]placeholderImage:[UIImage imageNamed:@"holder"]];
    self.imageViews.layer.cornerRadius = 10;
    self.imageViews.clipsToBounds = YES;

    self.label.text = _SelectionCellModel.title;
    
    
    
}

+(CGFloat)hightWithLable:(NSString *)lable{
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:15]};
    CGSize size = CGSizeMake(Labwidth - 20, CGFLOAT_MAX);
    CGRect rect = [lable boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return rect.size.height;
    
}

-(void)layoutSubviews{
    [super layoutSubviews];
    self.imageViews.frame = CGRectMake(5, 5, self.width - 10, self.height - 10);
    self.underImage.frame = CGRectMake(0, self.height - 60, self.width, 60);
    CGFloat labelHeight = 0;
    if (_SelectionCellModel.title.length > 0) {
        labelHeight = [LJFFuYongTableViewCell hightWithLable:_SelectionCellModel.title];
    }
    self.label.frame = CGRectMake(10, self.contentView.bottom - labelHeight - 10, Labwidth - 20, labelHeight);
    self.unserimageview.frame = CGRectMake(5, self.height - 45, self.width - 10, 40);
    
    
    
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
